package main

func main() {
	s := convert("PAYPALISHIRING", 3)
	println(s)
}

func convert(s string, numRows int) string {
	if numRows < 2 {
		return s
	}
	rows := make([]string, numRows)
	flag := -1
	j := 0
	for i := 0; i < len(s); i++ {
		rows[j] += s[i : i+1]
		if j == numRows-1 || j == 0 {
			flag = -flag
		}
		j += flag
	}
	res := ""
	for _, v := range rows {
		res += v
	}
	return res
}
